package com.itboye.lottery.utils;

import android.text.*;
import android.text.style.ForegroundColorSpan;
import android.text.style.TextAppearanceSpan;
import android.widget.TextView;
import com.itboye.lottery.app.MyApplication;
import com.itboye.lottery.R;


/**
 * Created by Administrator on 2017/3/22.
 */

public class HtmlTextUtil {
    public static void setColorfulValue(int startPo, int endPo, int color, String msg, TextView textView) {
        SpannableStringBuilder style = new SpannableStringBuilder(msg);
        style.setSpan(new ForegroundColorSpan(MyApplication.Companion.getInstance().getResources().getColor(color)), startPo, endPo, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        textView.setText(style);
    }

    public static void setColorfulValue2(int startPo, int endPo, int startPo2, int endPo2, int color, String msg, TextView textView) {
        SpannableStringBuilder style = new SpannableStringBuilder(msg);
        style.setSpan(new ForegroundColorSpan(MyApplication.Companion.getInstance().getResources().getColor(color)), startPo, endPo, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        style.setSpan(new ForegroundColorSpan(MyApplication.Companion.getInstance().getResources().getColor(color)), startPo2, endPo2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        textView.setText(style);
    }

//    public static void setDifferentSizeForTextView(int startPo, int endPo, String msg, TextView textView) {
//        SpannableString styledText = new SpannableString(Html.fromHtml(msg));
//        styledText.setSpan(new TextAppearanceSpan(MyApplication.Companion.getInstance(), R.style.index_top_text_style), startPo, endPo, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
////        styledText.setSpan(new TextAppearanceSpan(MyApplication.Companion.getInstance(), R.style.style1), 0, startPo, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
//        textView.setText(styledText, TextView.BufferType.SPANNABLE);
//    }
//
//
//    public static void setDifferentSizeForTextView2(int startPo, int endPo, String msg, TextView textView) {
//        SpannableString styledText = new SpannableString(Html.fromHtml(msg));
//        styledText.setSpan(new TextAppearanceSpan(MyApplication.Companion.getInstance(), R.style.account_book_textsize), startPo, endPo, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
//        textView.setText(styledText, TextView.BufferType.SPANNABLE);
//    }
}
